﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Practices.Unity;

namespace Framework
{
	public class ControllerActivator : IControllerActivator
	{
		#region IControllerActivator Members

		public IController Create(RequestContext requestContext, Type controllerType)
		{
			var controller = DependencyResolver.Current.GetService(controllerType) as IController ??
			                 Activator.CreateInstance(controllerType) as IController;
			return controller;
		}

		#endregion
	}
}